﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
namespace F1010DB
{
    public abstract  class ConnectionToDB 
    {
        private SqlTransaction tran = null;
        private SqlConnection conn = null;
        private string sqlConnection = string.Empty;


        private void getSqlString()
        {
            sqlConnection = setStringSQLServer();
        }

        protected abstract string setStringSQLServer();

        protected SqlConnection openConnect()
        {
            getSqlString();
            
            if (sqlConnection == string.Empty) { return null; }

            conn = new SqlConnection(sqlConnection);
            conn.Open();

            return conn;
        }

        protected void close(SqlConnection conn)
        {
            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
                conn = null;
            }
        }

      
    }
}
